<?php

namespace App\Http\Controllers\Api\V1\Queries;

use App\Models\Product;
use Spatie\QueryBuilder\QueryBuilder;
use Spatie\QueryBuilder\AllowedFilter;

class ProductQuery extends QueryBuilder
{
	public function __construct()
	{
		parent::__construct(Product::query());
		
		$this->allowedIncludes(['category', 'channel', 'attributeGroup', 'skus', 'slides', 'images'])
			->allowedFilters([
				'title',
				'title_long',
				AllowedFilter::exact('channel_id'),
				AllowedFilter::exact('is_delivery_free'),
				AllowedFilter::exact('is_returnable'),
				AllowedFilter::exact('is_sale'),
				AllowedFilter::exact('is_pop'),
				AllowedFilter::exact('is_rec'),
				AllowedFilter::exact('is_top'),
				AllowedFilter::exact('is_new'),
				AllowedFilter::exact('is_hot'),
				AllowedFilter::exact('is_top_100')
			]);
	}
}
